package com.worklog.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

import lombok.extern.slf4j.Slf4j;


//@Aspect
@Slf4j
//@Component
public class AspectPoint {
	@Pointcut("execution(* com.worklog.service.*.*(..))")
	public void pointCut() {

	}

	@Before("pointCut()")
	public void beforeAdd() {
		log.info("before========================");
	}

	@After("pointCut()")
	public void afterAdd() {
		log.info("@After========================");
	}

	@Around("pointCut()")
	public Object aroundAdd(ProceedingJoinPoint joinPoint) throws Throwable {
		log.info("@aroundAdd1========================");
		Object obj = null;
		obj = joinPoint.proceed();
		log.info("@aroundAdd2========================");
		return obj;
	}

	@AfterReturning(pointcut = "pointCut()",returning ="res")
	public void afterReturnAdd(Object res) {
		log.info("@afterReturnAdd========================" + res);
	}
	
	@AfterThrowing(throwing="e",pointcut = "pointCut()")
	public void afterThrowAdd(Throwable  e) {
		log.info("@afterReturnThrowAdd========================" + e.getMessage());
	}
}
